#ifndef QRCODE_H
#define QRCODE_H

#include "httprequestthread.h"

#include <QColor>
#include <QNetworkReply>
#include<QObject>
#include <QTimer>

namespace Ui {
class QrCode;
}

class QrCode : public QObject
{
    Q_OBJECT
    Q_PROPERTY(QString uuid READ getUuid WRITE setUuid NOTIFY uuidChanged)
    Q_PROPERTY(QColor color READ getColor WRITE setColor)
    Q_PROPERTY(bool ok READ getOk WRITE setOk NOTIFY okChanged)
    Q_PROPERTY(LOGIN_STATUS status READ getStatus WRITE setStatus NOTIFY statusChanged)
    Q_PROPERTY(QString imgUrl READ getImgUrl WRITE setImgUrl NOTIFY imgUrlChanged)

public:

    enum class LOGIN_STATUS {
        WAIT_SCAN = 0,
        SCAN = 1,
        CONFIRM = 2,
        OUTDATE = 3
    };
    Q_ENUM(LOGIN_STATUS)

    explicit QrCode();
    ~QrCode();

    QString getUuid() const;
    void setUuid(const QString &value);

    QColor getColor() const;
    void setColor(const QColor &value);

    bool getOk() const;
    void setOk(bool value);

    LOGIN_STATUS getStatus() const;
    void setStatus(const LOGIN_STATUS &value);

    QString getImgUrl() const;
    void setImgUrl(const QString &value);

signals:
    void uuidChanged(const QString& uuid);
    void statusChanged(const LOGIN_STATUS &value);
    void imgUrlChanged(const QString &value);
    void requestHttp();
    void okChanged();
    void tr();

protected slots:

private:
    QString uuid;
    QColor color;
    bool ok = false;
    LOGIN_STATUS status;
    QString imgUrl;
    HttpRequestThread httpRequest;
    QThread thread;
};

#endif // QRCODE_H
